#pragma once

#include "IReferenceCounter.h"
#include "Sol9Types.h"
#include "dimension2d.h"
#include "position2d.h"
#include "color.h"

namespace sol9
{
namespace graphics
{

	enum eColorFormat
	{
		ECF_Unknown,
		ECF_R8G8B8,
		ECF_A8R8G8B8,
	};

	enum eBlitOption
	{
		EBO_ImageCopy,
		EBO_ImageBlend,
	};

	class IImage : public IReferenceCounter
	{
		__declareBaseClass(IImage);

	public:
		virtual void* lock() = 0;
		virtual void unlock() = 0;

		virtual void blit(IImage* pOther, const core::position2di& Position = core::position2di(0), eBlitOption eOption = EBO_ImageCopy) = 0;
		virtual void fill(const color& cColor) = 0;

		virtual color getPixel(u32 x, u32 y) const = 0;
		virtual void setPixel(u32 x, u32 y, const color& c) = 0;

		virtual const core::dimension2du& getDimension() const = 0;
		virtual u32 getBitsPerPixel() const = 0;
		virtual u32 getBytesPerPixel() const = 0;
		virtual u32 getSizeInBytes() const = 0;
		virtual u32 getSizeInPixels() const = 0;
		virtual eColorFormat getColorFormat() const = 0;

		static u32 getBitsPerPixelFromFormat(const eColorFormat format)
		{
			switch (format)
			{
			case ECF_R8G8B8 :
				return 24;

			case ECF_A8R8G8B8 :
				return 32;

			default :
				return 0;
			}
		}
	};

} // namespace graphics
} // namespace sol9